fix(git): propagate exit codes in push/pull/fetch/stash/worktree#234
Open
polaminggkub-debug wants to merge 1 commit intortk-ai:masterfrom
Open
fix(git): propagate exit codes in push/pull/fetch/stash/worktree#234polaminggkub-debug wants to merge 1 commit intortk-ai:masterfrom
polaminggkub-debug wants to merge 1 commit intortk-ai:masterfrom
Conversation
run_push, run_pull, run_fetch, run_stash (pop/apply/drop/push and default), and run_worktree all printed FAILED messages on error but returned Ok(()) instead of propagating git's exit code. This breaks CI/CD pipelines and shell scripts that rely on exit code semantics (e.g. `git push || handle_error`). Fix: call std::process::exit(output.status.code().unwrap_or(1)) in each failure branch, matching the pattern already used in run_log, run_diff, run_add, and run_branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`rtk git push`, `rtk git pull`, `rtk git fetch`, `rtk git stash` (pop/apply/drop/push/default), and `rtk git worktree` all print a `FAILED:` message on error but return exit code 0 to the caller.
This breaks CI/CD pipelines and shell scripts that rely on exit code semantics:
```bash
rtk git push || handle_error # handle_error never called
rtk git pull && deploy # deploy runs even on pull failure
```
Root cause
The failure branches in these functions print the error but fall through to `Ok(())` instead of propagating git's exit code via `std::process::exit()`.
Fix
Add `std::process::exit(output.status.code().unwrap_or(1))` in each failure branch, matching the pattern already used correctly in `run_log`, `run_diff`, `run_add`, and `run_branch`.
Per the Rust docs, `status.code()` returns `Option` — `None` when the process was killed by a signal (Unix). The `.unwrap_or(1)` fallback handles that case correctly.
Functions fixed
Testing
All 412 existing tests pass. No new behavior on the success path.
🤖 Generated with Claude Code